package com.myway.service.impl;


import com.myway.dao.TabCityMapper;
import com.myway.dto.domain.CityDto;
import com.myway.dto.domain.CityJson;
import com.myway.pojo.TabCity;
import com.myway.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CityServiceImpl implements CityService {

    @Autowired
    private TabCityMapper tabCityMapper;



    //获取中文市列表
    @Override
    public CityDto selectInternalAbroadCity() {
        List<TabCity> tabCitiesDo = tabCityMapper.selectByExampleCityAF();
        //List<TabCity> tabCitiesAb = tabCityMapper.selectByExampleCityAF(2);
        List<CityJson> cityJsonDo= new ArrayList<CityJson>();
        for (TabCity dto : tabCitiesDo){
            CityJson json = new CityJson();
            json.setCityClass(dto.getAbbreviationCh());
            json.setCityName(dto.getCityCh());
            json.setCitySzm(dto.getCitySzm());
            cityJsonDo.add(json);
        }
        //获取中文市列表
        CityDto dto = new CityDto();
        dto.setTabCitiesDo(cityJsonDo);
        return dto;
    }




    //获取英文市列表
    @Override
    public CityDto selectInternalForeignCity() {
        List<TabCity> tabCitiesDo = tabCityMapper.selectByExampleCityAF();
        List<CityJson> cityJsonDo= new ArrayList<CityJson>();

        for (TabCity dto : tabCitiesDo){
            CityJson json = new CityJson();
            json.setCityClass(dto.getAbbreviationEn());
            json.setCityName(dto.getCityEn());
            json.setCitySzm(dto.getCitySzm());
            cityJsonDo.add(json);
        }

        //获取中文市列表
        CityDto dto = new CityDto();
        dto.setTabCitiesDo(cityJsonDo);
        return dto;
    }


}
